<?php
/**
 * User: bim bip
 * Date: 8/1/11
 * Time: 3:22 PM
 */
class UserModel extends CI_Model{
    var $_name;
    var $_password;
    var $_title;
    private $_table = 'user';

    function __construct(){
     parent::__construct();
    }

    /**
    * @return bool
    */
    function isLogin(){
        return true;
    }

    /**
    * @return string - title
    */
    function getTitle(){

    }

    /**
     * @return void
     */
    function isAdmin(){
        $this->db->cache_off();
        $sql = "SELECT g.title, u.password
                FROM user u, user_group g
                WHERE u.user_group_id = g.user_group_id AND u.name = '$this->_name'
                LIMIT 0, 1";
        $query = $this->db->query($sql);
        $result = $query->row_array();
        if(count($result) == 0 )
            return false;

        if($result['password'] == $this->_password && $result['title'] == 'Administrator')
            return true;
        else
            return false;
    }
}
